package com.javalong.mir.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.javalong.mir.dao.BannerDao;
import com.javalong.mir.pojo.Banner;

@Service
public class BannerService {

	@Autowired
	private BannerDao bannerDao;
	
	public List<Banner> getList(int page,int pageSize){
		return bannerDao.findAll(page, pageSize);
	}
	
	public void save(Banner welfareStory){
		bannerDao.save(welfareStory);
	}
	
	public int getCount(){
		return bannerDao.getCount();
	}
	
	public List<Banner> getBannerList(int beginRow,int pageSize){
		return bannerDao.findAll(beginRow, pageSize);
	}
	
	public Banner findBannerById(int id){
		return bannerDao.findById(id);
	}
	
	public void delete(int id){
		bannerDao.delete(id);
	}
	
	public void updateBanner(Banner welfareStory){
		welfareStory.setUpdateAt(new Date());
		bannerDao.update(welfareStory);
	}
	
	public Banner getLastBanner(){
		return bannerDao.getLastBanner();
	}
	
}
